﻿Imports DTO
Imports System.Data.OleDb
Public Class DangNhapDAO
    Public Function KiemTraDangNhap(ByVal _tendangnhap As String, ByVal _matkhau As String) As Integer
        Dim sql As String
        sql = "SELECT COUNT(*)FROM TAIKHOANNGUOIDUNG WHERE TenDangNhap = @tendangnhap AND MatKhau = @matkhau"
        Dim conn As OleDbConnection = DatabaseProvider.connectData() '(.connectionDB)
        conn.Open()
        Dim command As OleDbCommand
        command = New OleDbCommand(sql, conn)
        command.Parameters.Add("@tendangnhap", OleDbType.VarWChar).Value = _tendangnhap
        command.Parameters.Add("@matkhau", OleDbType.VarChar).Value = _matkhau
        Dim reader As OleDbDataReader = command.ExecuteReader()
        While reader.Read()
            If reader.GetInt32(0) = 1 Then
                Return 1
            End If

        End While
        conn.Close()
        Return 0
    End Function
End Class
